package com.github_Dididipapa.shortlink.admin.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: To be defined
 * @author: dididi_papa
 * @email: mitis1624087624@gmail.com
 * @date: 2025/09/15  21:44
 */
@Configuration
public class RedissonConfig {

    @Value("${define.host}")
    private String host;
    @Value("${define.username}")
    private String username;
    @Value("${define.password}")
    private String password;

    @Bean("redisson")
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + host);
        config.useSingleServer().setDatabase(0);
        //config.useSingleServer().setUsername(username);
        config.useSingleServer().setPassword(password);
        return Redisson.create(config);
    }
}
